package com.chinackts.proceedspayment.importpayment.controller;

import com.alibaba.fastjson.JSONObject;
import com.chinackts.proceedspayment.importpayment.dto.ImportPaymentListDto;
import com.chinackts.proceedspayment.importpayment.query.ImportPaymentPageQuery;
import com.chinackts.proceedspayment.importpayment.query.ImportPaymentQuery;
import com.chinackts.proceedspayment.importpayment.service.ImportPaymentService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @author Lianhong
 * @since 2021/11/18
 */
@RestController
public class ImportPaymentController implements ImportPaymentControllerInterface {

    @Resource
    private ImportPaymentService importPaymentService;

    @Override
    public ResponseEntity<ImportPaymentListDto> list(String id, ImportPaymentQuery query) {
        return ResponseEntity.ok(importPaymentService.list(id, query));
    }

    @Override
    public ResponseEntity<ImportPaymentListDto> pageList(String id, ImportPaymentPageQuery query) {
        return ResponseEntity.ok(importPaymentService.pageList(id, query));
    }

    @Override
    public ResponseEntity<JSONObject> details(String id, String entryId, boolean regather) {
        return ResponseEntity.ok(importPaymentService.details(id, entryId, regather));
    }

    @Override
    public ResponseEntity<Void> importPaymentPdf(String id, List<String> entryIds, HttpServletResponse response) {
        importPaymentService.exportProceedsPdf(id, entryIds, response);
        return ResponseEntity.noContent().build();
    }
}
